﻿//  --------------------------------
//  Copyright (c) 2010 Michael Schuler, Sascha Burger. All rights reserved.
//  This source code is made available under the terms of the Microsoft Public License (Ms-PL)
//  http://p2pmessaging.codeplex.com/license
//  ---------------------------------
namespace p2pMessaging.Interfaces
{
	/// <summary>
	/// Generic interface for services to persist entities.
	/// </summary>
	public interface IPersistenceService
	{
		/// <summary>
		/// Store entity <paramref name="t"/> persistent.
		/// </summary>
		/// <param name="t">Instance of <see cref="T"/>.</param>
		/// <typeparam name="T">Type of <see cref="IPersistenceEntity"/>.</typeparam>
		void Store<T>(T t) where T : IPersistenceEntity;

		/// <summary>
		/// Remove entity <paramref name="t"/> from the persistent store.
		/// </summary>
		/// <param name="t">Instace of <see cref="T"/>.</param>
		/// <typeparam name="T">Type of <see cref="IPersistenceEntity"/>.</typeparam>
		void Delete<T>(T t) where T : IPersistenceEntity;

		/// <summary>
		/// Get an entity by its id.
		/// </summary>
		/// <param name="id">Unique id of the instace.</param>
		/// <typeparam name="T">Type of <see cref="IPersistenceEntity"/>.</typeparam>
		/// <returns>Instance of <see cref="T"/> if found otherwise null.</returns>
		T Get<T>(string id) where T : IPersistenceEntity;
	}
}
